package com.original.simuladores.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.original.simuladores.dao.TaxIndexDao;
import com.original.simuladores.entities.TaxIndex;
import com.original.simuladores.service.TaxIndexService;

public class TaxIndexServiceImpl implements TaxIndexService {

	@Autowired
	TaxIndexDao taxIndexDao;
	
	@Override
	public List<TaxIndex> getTaxIndexById(String id) {
		return taxIndexDao.read(TaxIndex.class, id);
	}

	@Override
	public List<TaxIndex> getTaxIndexs() {
		return taxIndexDao.read(TaxIndex.class);
	}

	@Override
	public String create(TaxIndex ti) {
		return (String) taxIndexDao.create(ti);
	}

	@Override
	public String delete(TaxIndex ti) {
		return (String) taxIndexDao.delete(TaxIndex.class, ti.getId());
	}

	@Override
	public String update(TaxIndex ti) {
		return (String) taxIndexDao.update(ti);
	}

	@Override
	public String getId() {
		List<TaxIndex> ls = taxIndexDao.lastestObject(TaxIndex.class);
		String idReturn = "1";
		if (ls != null && ls.size() > 0) {
			TaxIndex obj = ls.get(0);
			Integer id = Integer.valueOf(obj.getId())  + 1;
			idReturn = id.toString();
		}
		return idReturn;
	}

}
